package _1_初级._5_排序和搜索._5_1_排序;

import com.alibaba.fastjson.JSON;

public class _1_冒泡排序 {

    /**
     *
     * @param nums
     * @return
     * 参考：https://www.cnblogs.com/bigdata-stone/p/10464243.html
     */

    public static int[] sortArray(int[] nums){

        int temp;
        for(int i = 0; i < nums.length; i++){
            for(int j = 0; j < nums.length - i - 1; j++){
                if(nums[j] > nums[j + 1]){
                    temp = nums[j + 1];
                    nums[j + 1] = nums[j];
                    nums[j] = temp;
                }
            }
        }

        return nums;
    }

    public static void main(String[] args) {
        int[] nums = new int[]{10,1,35,61,89,36,55};
        System.out.println(JSON.toJSONString(sortArray(nums)));
    }

}
